<template>
  <div class="section">
    <v-calendar
      class="custom-calendar"
      :masks="masks"
      :attributes="list"
      disable-page-swipe
      is-expanded
      @update:to-page="month_chage"
    >
      <template v-slot:day-content="{ day, attributes }">
        <div class="date-area" @click="$emit('onDateClick', day)">
          <span class="date">{{ day.day }}</span>
          <div v-if="attributes && attributes.length" class="s-list">
            <el-tag
              v-for="(attr, i) in attributes[0].customData.list"
              :key="i"
              size="small"
              :type="attributes[0].customData.is_rest == 1 ? 'info' : 'primary'"
              style="margin:2px 0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"
            >
              {{ attr.section_name }}
            </el-tag>
          </div>
        </div>
      </template>
    </v-calendar>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      masks: {
        weekdays: "WWW"
      }
    };
  },
  methods: {
    month_chage(date) {
      this.$nextTick(() => {
        this.$emit("change", date);
      })
    }
  }
};
</script>

<style lang="less" scoped>
.section {
  width: 100%;
  max-width: 800px;
  .date-area {
    overflow: auto;
    height: 100%;
    .date {
      font-size: 14px;
      font-weight: bold;
      color: #333;
    }
  }
}

::-webkit-scrollbar {
  width: 0px;
}
::-webkit-scrollbar-track {
  display: none;
}
/deep/ .custom-calendar.vc-container {
  --day-border: 1px solid #b8c2cc;
  --day-border-highlight: 1px solid #b8c2cc;
  --day-width: 90px;
  --day-height: 110px;
  --weekday-bg: #f8fafc;
  --weekday-border: 1px solid #eaeaea;
  border-radius: 0;
  max-width: 600px;
  & .vc-header {
    background-color: #f1f5f8;
    padding: 10px 0;
  }
  & .vc-weeks {
    padding: 0;
  }
  & .vc-weekday {
    background-color: var(--weekday-bg);
    border-bottom: var(--weekday-border);
    border-top: var(--weekday-border);
    padding: 5px 0;
  }
  & .vc-day {
    padding: 0 5px 3px 5px;
    text-align: left;
    height: var(--day-height);
    min-width: var(--day-width);
    background-color: white;
    &.weekday-1,
    &.weekday-7 {
      background-color: #eff8ff;
    }
    &:not(.on-bottom) {
      border-bottom: var(--day-border);
      &.weekday-1 {
        border-bottom: var(--day-border-highlight);
      }
    }
    &:not(.on-right) {
      border-right: var(--day-border);
    }
  }
  & .vc-day-dots {
    margin-bottom: 5px;
  }
}
</style>
